<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<base href="<%=basePath%>">
<title>代理商</title>
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/bootstrap.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/css/main.css">
<script src="${pageContext.request.contextPath}/js/jquery.min.js"></script>
<script src="${pageContext.request.contextPath}/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/js/main.js"></script>
<style>
.main_div {
	min-width: 1000px
}

.main_div {
	min-height: 60px
}

.force-overflow1-1 {
	border: none
}

.vipQuantity {
	color: #101011;
	font-size: 18px;
	font-weight: 400;
	line-height: 60px
}

.vipQuantity>p>span {
	color: #e01d0a
}

.pageChange {
	float:right;
	color: #337ab7;
}

.pageChange>span {
	cursor: pointer
}

.pageChange>span:hover {
	color: blue
}
</style>


</head>
<body>
	<%@ include file="header.jsp"%>
	<%@ include file="left.jsp"%>
	<div id="index"
		style="position: absolute;left: 180px;top: 80px;bottom: 0;right: 0;">
		<section id="main">
			<div class="scrollbar1-1" id="style1-1">
				<div class="main_div">
					<div class="main_title">
						<span>会员统计</span>
					</div>					
				</div>
				<div class="force-overflow1-1">
				    <div class="vipQuantity">
                <p>该超市共有<span id="vipCount"></span>名会员</p>
            </div>
					<table class="table table-condensed table-bordered table-hover"
						 style="text-align: center" id="showtable">
						<tr style="background-color: #59c7d2">
							<th style="text-align: center">序号</th>
							<th style="text-align: center">用户名</th>
							<th style="text-align: center">注册时间</th>
							<th style="text-align: center">订单数量</th>
							<th style="text-align: center">总金额</th>
							<th style="text-align: center">平均金额</th>
						</tr>
					</table>
					<div class="pageChange">
						<span onclick="prePage()">&nbsp;&nbsp;上一页&nbsp;&nbsp;</span> <span
							onclick="nextPage()">&nbsp;&nbsp;下一页&nbsp;&nbsp;</span> <em>
							&nbsp; 第&nbsp;<span id="pageNum">1</span>&nbsp;页&nbsp;&nbsp;
						</em> <em>/&nbsp;&nbsp;共&nbsp;<span id="totalpage"></span>&nbsp;页
						</em> <em>&nbsp;&nbsp;&nbsp;跳到第<input id="searchInput"
							style="width:46px" maxlength="4" type="text">页
						</em>
						<button type="submit" class="btn btn-primary"
							onclick="searchPage()">搜索</button>
							<input style="display:none" value="8" id="pageCount"
						name="pageCount" />
					</div>
				</div>
			</div>
		</section>
	</div>
</body>
<script type="text/javascript">
	$(function() {
		selectinfo();
		
	})

	function selectinfo() {
	    var URL = document.location.toString();
		var sperIDs = URL.split("=")[1]
		var pageNum = $("#pageNum").html();
		var pageCount = $("#pageCount").val();
		$.get(urls+"agentAction/getUserInfo",
			{
			pageNum : pageNum,
			pageCount : pageCount,
			belongSupermarket:sperIDs,		
			},
			function(data) {
			 // console.log(data)
				if (data) {
					var totalpage = data.totalpage;
					var orderlist = data.drawingslist;
					var table = $("#showtable");
					$("tr").remove(".addtr");
					$("#vipCount").html(data.totalVip);
					for (var i = 0; i < orderlist.length; i++) {
						var average = "";
						if (orderlist[i].orderNum < 0) {
							average = "-"
						} else {
							average = parseFloat(orderlist[i].consumeMoney / orderlist[i].orderNum).toFixed(2)
						}
						var append = "<tr class='addtr'><td>" + (i + 1) + "</td>" +
							"<td >" + orderlist[i].userName + "</td>" +
							"<td>" + orderlist[i].registrationDate + "</td>" +
							"<td>" + orderlist[i].orderNum + "</td>" +
							"<td>" + orderlist[i].consumeMoney + "</td>" +
							"<td>" + average + "</td></tr>";
						table.append(append);
					}
					$("#totalpage").html(totalpage);
				}
			}
			, "json"
		)
	}
	function returninfo(e) { //退货	    
		$.post(urls+"orderFormAction/disposeReturn",
			{
				orderFormID : e.id
			},
			function(res) {
				if (res) {
					alert("处理成功")
					e.value = "已处理"
					e.disabled = "true"
				} else {
					alert("处理失败")
				}
			}
		)
	}

	
</script>
</html>
